{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>
                                    <div class="layui-table-cell">订单号</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商品名称</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">规格</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">商品图册</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">单价</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">总价</div>
                                </th>
                                <th>
                                    <div class="layui-table-cell">购买数量</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>
                                    <div class="layui-table-cell">{$v.ordersn|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.title|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.name|default=''}</div>

                                </td>
                                <td>
                                    <div id="layer-photos-demo" class="layer-photos-demo">
                                        {foreach $v.images as $k=> $vs}
                                        <img layer-pid="" style="height: 40px;" layer-src="{$vs|default=''}"
                                            src="{$vs|default=''}" alt="{$v.title|default=''}">
                                        {/foreach}
                                    </div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.price|default='0'}元/{$v.unmit|default=''}</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.total|default='0'}元</div>
                                </td>
                                <td>
                                    <div class="layui-table-cell">{$v.number|default='0'}*{$v.unmit|default=''}</div>
                                </td>
                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
{include file="public/footer"}
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;
        //监听省份选择
        form.on('select(province)', function (data) {
            if (!data.value) {
                $('select[name="city"]').html('');
                $('select[name="area"]').html('');
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 2 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择城市</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="city"]').html(str);
                        $('select[name="area"]').html('');
                        $('select[name="street"]').html('');
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听城市选择
        form.on('select(city)', function (data) {
            if (!data.value) {
                $('select[name="area"]').html('');
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 3 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择区域</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.area_code;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="area"]').html(str);
                        $('select[name="street"]').html('');
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听区域选择
        form.on('select(area)', function (data) {
            if (!data.value) {
                $('select[name="street"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getregion',
                data: { area_code: data.value, level: 4 },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择街道</option>';
                        $.each(res.data, function (i, obj) {
                            str += '<option value="' + obj.id;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="street"]').html(str);
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
        //监听分类 
        form.on('select(platclassid)', function (data) {
            if (!data.value) {
                $('select[name="sonsid"]').html('');
                form.render();
                return false;
            }
            //发异步，把数据提交给php
            $.ajax({
                type: 'get',
                url: '/base/getsons',
                data: { classid: data.value },
                success: function (res) {
                    if (res.status == 0) {
                        var str = '<option value="">请选择分类</option>';
                        $.each(res.data, function (i, obj) {
                            console.log(obj);
                            str += '<option value="' + obj.id;
                            str += '">' + obj.name;
                            str += '</option>';
                        });
                        $('select[name="sonsid"]').html(str);
                        form.render();
                    } else {
                        layer.msg(res.msg, { icon: 2, time: 1000 });
                    }
                }
            });
            return false;
        });
    });
</script>
</body>